<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/public/BaseCms.php");

class Usersinfo extends BaseCms
{
    public $tb_name = "usersinfo";

    function __construct()
    {
        parent::__construct($this->tb_name);
    }

    public function login($userName, $password, $code)
    {
        $cond = ["user_name" => $userName];
        $captcha = $_SESSION["captcha"];
        if ($captcha !== $code) {
            die("请输入正确的验证码");
        }

        $data = parent::findOne($cond);
        if (empty($data)) {
            die("用户名或者密码错误");
        }
        if ($data["password"] === md5($password)) {
            return "success";
        } else {
            die("请输入正确的验证码");
        }
    }

}